<div class="layui-card-header">
    <h2 class="header-title">修改个人信息</h2>
</div>
<div class="layui-card-body" style="padding: 30px;">
    <form class="layui-form layui-form-pane" id="form-personal">
        <input name="pid" type="hidden" th:field="${user.pid}"/>
        <div class="layui-form-item">
            <label class="layui-form-label">用户名称</label>
            <div class="layui-input-block">
                <input name="userName" placeholder="请输入用户名称" type="text" class="layui-input" maxlength="20"
                       lay-verify="required" required th:field="${user.userName}"/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">手机号码</label>
            <div class="layui-input-block">
                <input name="mobileNo" placeholder="请输入手机号码" type="text" class="layui-input" lay-verify="required|phone"
                       required th:field="${user.mobileNo}"/>
            </div>
        </div>
        <div class="layui-form-item">
            <button class="layui-btn layui-btn-fluid" lay-submit lay-filter="submit-personal">确认修改</button>
        </div>
    </form>
</div>

<script>
    layui.use(['layer', 'jquery', 'form', 'sadmin'], function () {
        var $ = layui.$ //重点处
        var layer = layui.layer;
        var form = layui.form;
        var sadmin = layui.sadmin;

        //监听提交
        form.on('submit(submit-personal)', function (data) {
            layer.load(2);
            $.post('/home/setPersonal', data.field, function (result) {
                layer.closeAll('loading');
                if (result.success) {
                    sadmin.closePopupRight();
                    layer.msg(result.msg);
                }
                else {
                    layer.closeAll('loading');
                    layer.msg(result.msg);
                }
            });
            return false;
        });
    });
</script>